<?php
require '../config.php';
$codigoLlamada = $_REQUEST['codigollamada'];
$query="select efectividad,nota,motivo from regllamadas where idregllamadas = '".$codigoLlamada."'";

$resultset = mysql_query($query,$conexion);

if(!$resultset)
{
    mysql_close();
    echo json_encode('error en el query: ' . mysql_error());
}
elseif(!mysql_num_rows($resultset))
{
    mysql_close();
    echo json_encode('Sin resultados');
}
else
{
	$row = mysql_fetch_array($resultset);
	
	echo "<ul class='list-unstyled'>";
		echo "<li>";
		echo "<label class='description' >Efectividad: </label>";
		echo "<input id='m_monto' class='element text medium' maxlength='8'   type='text' value='".$row['efectividad']."'>";
		echo "</li>";
		echo "<li>";
		echo "<label class='description' >Observaci&oacute;n: </label>";
		echo "<input id='m_obse' class='element text medium' maxlength='50'   type='text' value='"._convert($row['nota'])."'>";
		echo "</li>";
		echo "<li>";
		echo "<label class='description' >Motivo de llamada: </label>";
		echo "<input id='m_moti' class='element text medium' maxlength='50'   type='text' value='"._convert($row['motivo'])."'>";
		echo "</li>";
	echo "</ul>";
	mysql_close();
}
function _convert($content) {
	if(!mb_check_encoding($content, 'UTF-8')
	OR !($content === mb_convert_encoding(mb_convert_encoding($content, 'UTF-32', 'UTF-8' ), 'UTF-8', 'UTF-32'))) {

		$content = mb_convert_encoding($content, 'UTF-8');

		if (mb_check_encoding($content, 'UTF-8')) {
			// log('Converted to UTF-8');
		} else {
			// log('Could not converted to UTF-8');
		}
	}
	return $content;
}

?>